package com.qingluan.widget;

import com.qingluan.dd.R;
import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
import android.widget.EditText;

public class AddTagTimeActivity extends Activity {
	//widget arguments area
	private EditText tag;
	private EditText Hour;
	private EditText Minute;
	
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_detail_mission_info);
		tag = (EditText)findViewById(R.id.add_mission_tag);
		Hour = (EditText)findViewById(R.id.dead_time_hour);
		Minute = (EditText)findViewById(R.id.dead_time_minutes);
		
		
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.detail_mission_info, menu);
		return true;
	}
	
	public void callBack(View v){
		String[] Tags = OperationTag();
		String time = OperationTime();
		Intent intent = getIntent().putExtra("tags", Tags);
		intent.putExtra("time", time);
		this.setResult(RESULT_OK, intent);
		this.finish();
	}
	
	
	public String[] OperationTag(){
		String Info = tag.getText().toString();
		String []Tags = Info.split(" ");
		return Tags;
	}
	
	public String OperationTime(){
		
		String hour = null;
		String minute  =null;
		
		if ((hour =Hour.getText().toString()).length() < 1){
			hour = Hour.getText().toString();
		}else {
			Hour.requestFocus();
		}
		
		if ((minute = Minute.getHint().toString()).length() < 1){
			minute = Minute.getText().toString();
		}else {
			Minute.requestFocus();
		}
		
		String time = hour;
		return time;
	}
}
